package com.vinfai.patterns.proxy.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

public class MyInvocationHandler implements InvocationHandler {
	private Logger logger = LogManager.getLogger(MyInvocationHandler.class);
	
	private Object proxied;
	
	public MyInvocationHandler(Object proxied){
		this.proxied = proxied;
	}
	@Override
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		logger.info(method.getName()+";");
		for(Object arg : args){
			logger.info("args: "+arg);
		}
		Object rs = method.invoke(proxied, args);
		return rs;
	}

}
